package com.example.multidrive;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseSQL extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = "projetoTP.db";
	private static final int DATABASE_VERSION = 1;

	private static final String DATABASE_CREATE_NOTAS = "CREATE TABLE notas("
			+ "idNota INTEGER PRIMARY KEY AUTOINCREMENT," + "titulo VARCHAR,"
			+ "texto VARCHAR," + "nomeDisciplina VARCHAR);";
	private static final String DATABASE_CREATE_DISCIPLINAS = "CREATE TABLE disciplinas("
			+ "idDisciplina INTEGER PRIMARY KEY AUTOINCREMENT,"
			+ "nome VARCHAR);";

	public DatabaseSQL(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DATABASE_CREATE_NOTAS);
		db.execSQL(DATABASE_CREATE_DISCIPLINAS);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF NOT EXISTS notas");
		db.execSQL("DROP TABLE IF NOT EXISTS disciplinas");
		onCreate(db);
	}

}
